home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 7 / Apprentice-Release7.iso / Utilities / Miscellaneous / CopyPaste 3.3.4 / CopyPaste Tools Sourcecode / e-mail UnComment / e-mail UnComment.p < prev    next >
Encoding:
Text File  |  1997-06-06  |  2.3 KB  |  96 lines  |  [TEXT/CWIE]

  1. {•This sourcecode is an example for creating a FKey coderesource with•}
  2. {•Metrowerks Pascal. It is copyrighted by Peter Hoerster and released•}
  3. {•for free use in any Shareware or Freeware product as a way to thank all•}
  4. {•programmers who share code snippets. You may put this sources on any•}
  5. {•CD ROM or any Archive Server but you may not sell it. •}
  6.  
  7. {• For comments please write to <hoerster@muenster.de>•}
  8.  
  9.  
  10.  
  11. unit eUnComment;
  12.  
  13. interface
  14.  
  15.     uses
  16.         Types, OSUtils, GestaltEqu, Script, notification, Resources, Events,
  17.          PascalA4, QuickDraw, ToolUtils, Memory, LowMem, Scrap;
  18.  
  19.  
  20.  
  21. {$MAIN}
  22.                         
  23.     procedure main;        
  24.  
  25. implementation
  26.  
  27.     procedure dopaste;
  28.     const
  29.         pastecode=2422;
  30.     var 
  31.         qel: EvQelPtr;
  32.     begin
  33.             if ppostevent(3, pastecode, qel) = noerr then
  34.             qel^.evtqmodifiers := cmdkey;
  35.     end;
  36.  
  37.     
  38.     
  39.     procedure main;
  40.         const
  41.             step = 1000;
  42.             tab = char(ord(9));
  43.             esc = char(ord(27));
  44.             Enter = char(ord(3));                                {the enter character}
  45.             Return = char(ord(13));                                {the return character}
  46.         Type
  47.             chararray=packed array[1..1]of char;
  48.             chararrayptr=^chararray;
  49.             chararrayhdl=^chararrayptr;
  50.         var
  51.             oldA4: LongInt;
  52.             myerr: oserr;
  53.             myclipsize, templongint: longint;
  54.             myclipHandle: handle;
  55.             substhandle: Handle;
  56.             i: integer;
  57.             subst: str15;
  58.             wasreturn:boolean;
  59.     begin
  60.         oldA4 := SetCurrentA4;
  61.         wasreturn:=false;
  62.         myclipsize := GetScrap(nil, 'TEXT', templongint);
  63.         mycliphandle := Tempnewhandle(myclipsize,myerr);
  64.         if myerr=noerr then 
  65.             begin
  66.                 myclipsize := GetScraP(myclipHandle, 'TEXT', templongint);
  67.                 if myclipsize > 0 then
  68.                     begin
  69.                         while (chararrayhdl(mycliphandle)^^[1]='>') do
  70.                             begin
  71.                                 myclipsize:=myclipsize-1;
  72.                                 blockmove( pointer(ord4(mycliphandle^)+1),mycliphandle^,myclipsize);
  73.                             end;
  74.                         sethandlesize(mycliphandle,myclipsize);
  75.                         
  76.                         subst :=return;
  77.                         subst[1] := return;
  78.                         substhandle := newhandle(1);
  79.                         blockmove(@subst[1], substhandle^,1);
  80.                         subst := '12';
  81.                         subst[1]:=return;
  82.                         subst[2]:='>';
  83.                         i := ReplaceText(mycliphandle, substhandle, subst);
  84.                         
  85.                         myerr := ZeroScrap;
  86.                         myclipsize:=gethandlesize(mycliphandle);
  87.                         Temphlock(mycliphandle,myerr);
  88.                         myerr := putscrap(myclipsize, 'TEXT', myclipHandle^);
  89.                         Temphunlock(myCliphandle,myerr);
  90.                         dopaste;
  91.                     end;
  92.             end;
  93.         TempDisposeHandle(myCliphandle,myerr);
  94.         oldA4 := SetA4(oldA4);
  95.     end;
  96. end.